// import com.alibaba.druid.sql.ast.SQLExpr_ptr;
// import com.alibaba.druid.sql.ast.SQLName_ptr;
// import com.alibaba.druid.sql.ast.SQLStatementImpl;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "SQLOptimizeStatement.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../../../utils/listTran.h"
#include "SQLExprTableSource.h"

SQLOptimizeStatement::SQLOptimizeStatement()
{
  tableSources = std::make_shared<std::list<SQLExprTableSource_ptr>>();
}

BOOL_ptr SQLOptimizeStatement::isFinal()
{
  return isFinal_;
}

void SQLOptimizeStatement::setFinal(BOOL_ptr isFinal)
{
  this->isFinal_ = isFinal;
}

BOOL_ptr SQLOptimizeStatement::isDeduplicate()
{
  return deduplicate;
}

void SQLOptimizeStatement::setDeduplicate(BOOL_ptr deduplicate)
{
  this->deduplicate = deduplicate;
}

SQLExpr_ptr SQLOptimizeStatement::getDeduplicateBy()
{
  return deduplicateBy;
}

void SQLOptimizeStatement::setDeduplicateBy(SQLExpr_ptr deduplicateBy)
{
  this->deduplicateBy = deduplicateBy;
}

SQLExprTableSource_list_ptr SQLOptimizeStatement::getTableSources()
{
  return tableSources;
}

void SQLOptimizeStatement::addTableSource(SQLExprTableSource_ptr tableSource)
{
  if (tableSource != nullptr)
  {
    tableSource->setParent(SharedObject(SQLOptimizeStatement));
  }
  this->tableSources->push_back(tableSource);
}

SQLName_ptr SQLOptimizeStatement::getCluster()
{
  return cluster;
}

void SQLOptimizeStatement::setCluster(SQLName_ptr cluster)
{
  this->cluster = cluster;
}

// @Override
void SQLOptimizeStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLOptimizeStatement)))
  {
    SQLObject_list_ptr tmp = ListTran::tran_class<SQLExprTableSource, SQLObject>(tableSources);
    acceptChild(visitor, tmp);
    acceptChild(visitor, cluster);
  }
  visitor->endVisit(SharedObject(SQLOptimizeStatement));
}
